home *** CD-ROM | disk | FTP | other *** search
- #!/usr/local/bin/stk -f
- ;;;; s e r v e r . s t k -- A simple sever
- ;;;;
- ;;;; Copyright ⌐ 1993-1996 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
- ;;;;
- ;;;; Permission to use, copy, and/or distribute this software and its
- ;;;; documentation for any purpose and without fee is hereby granted, provided
- ;;;; that both the above copyright notice and this permission notice appear in
- ;;;; all copies and derived works. Fees for distribution or use of this
- ;;;; software or derived works may only be charged with express written
- ;;;; permission of the copyright holder.
- ;;;; This software is provided ``as is'' without express or implied warranty.
- ;;;;
- ;;;; This software is a derivative work of other copyrighted softwares; the
- ;;;; copyright notices of these softwares are placed in the file COPYRIGHTS
- ;;;;
- ;;;; Author: Erick Gallesio [eg@kaolin.unice.fr]
- ;;;; Creation date: 4-Feb-1995 18:17
- ;;;; Last file update: 12-Feb-1995 11:57
-
- (define s (make-server-socket))
-
- (dynamic-wind
- ;; Init: Launch an xterm with telnet running on the s listening port and connect
- (lambda ()
- (run-process "xterm" "-e" "telnet" "localhost"
- (number->string (socket-port-number s)))
- (socket-accept-connection s)
- (format (socket-output s) "\nWelcome on the socket REPL.\n\n> ")
- (flush (socket-output s)))
-
- ;; Action: A toplevel like loop
- (lambda ()
- (let loop ()
- (format (socket-output s) "; Result: ~s\n> " (eval (read (socket-input s))))
- (flush (socket-output s))
- (loop)))
-
- ;; Termination: We go here when
- ;; a) an error occurs
- ;; b) connection is closed
- (lambda ()
- (format #t "Shutdown ......\n")
- (socket-shutdown s)))
-